#ifndef MATERIAL_BASE_H
#define MATERIAL_BASE_H

class Material;

#include <string>
#include <map>
#include <istream>
#include "color.h"
#include "collision.h"

class Scene;

class Material
{
  public:
    Material(Scene *scene);
    virtual ~Material() = 0;
    virtual void loadAttributes(std::istream &istream) = 0;
    virtual void computeColor(Collision c, Color &targetColor) = 0;
    static void cache(std::string name, Material *m);
    static Material* getMaterial(std::string materialName);
  protected:
    void m_castTransparentRay(Collision c, double ior, Color &targetColor);
    void m_castReflectRay(Collision c, Color &targetColor);
    void m_castLightRays(Collision c, Color &diffuseColor, Color &specularColor);
    Scene *m_scene;
  private:
    static std::map<std::string, Material*> s_materials;
};
#endif
